package ltd.newbee.mall.util.paypal;

import com.paypal.core.PayPalHttpClient;
import com.paypal.http.HttpResponse;
import com.paypal.orders.Order;
import com.paypal.orders.OrderRequest;
import com.paypal.orders.OrdersCaptureRequest;

import java.io.IOException;

/**
 * 扣款order
 * @author pyw
 */
public class CaptureOrder implements OrderAbstractHandler {
    @Override
    public OrderRequest buildRequestBody() {
        return new OrderRequest();
    }

    /**
     *
     * @param id 订单id
     * @param client
     * @return
     * @throws IOException
     */
    @Override
    public HttpResponse<Order> getResponseMessage(String id, PayPalHttpClient client) throws IOException {
        OrdersCaptureRequest request = new OrdersCaptureRequest(id);
        request.requestBody(buildRequestBody());
        return client.execute(request);
    }
}
